<!--
Tasks by Statuses / Situação por Tarefas 
-->
<script type="text/javascript">
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
			credits: {
	 		  enabled: false
			},
            chart: {
                renderTo: 'container',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: '<%=@project.name%>'
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.y,0) +' <%=t :tasks_label%>';
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage,2) +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                data: <%=@statuses.map{ |situacao| [situacao.name.to_s, situacao.totalissues.to_i]}.inspect.html_safe%>
            }]
        });
    });
    
});

</script>
<script type="text/javascript">
var chart;
$(document).ready(function() {
	chart = new Highcharts.Chart({
     	credits: {
 		  enabled: false
		},		
		chart: {
			renderTo: 'containerColumn',
			type: 'column'
		},
		title: {
			text: '<%=t :statuses_issue_label_title %>'
		},
		xAxis: {
			categories: <%=@statuses.map{ |situacao| situacao.name.to_s}.inspect.html_safe%>,
			labels: {enabled: false}
		},
		yAxis: {
			min: 0,
			title: {
				text: '<%=t :tasks_label%> ',
			}
		},
		legend: {
			enabled: true
		},
		tooltip: {
			formatter: function() {
				return '<b>'+ this.series.name +'</b><br/>'+
					'<%=t :tasks_label%> '+ Highcharts.numberFormat(this.y, 0);
			}
		},
        series: [
                <%@statuses.each do |cat|%>
                {
                        name: <%=cat.name.inspect.html_safe%>,
                        data: [<%=cat.totalissues%>],
                        cursor: 'pointer',
                        events: {
                                // Default action for (left) clicking the data
                                click: function(point) {
                                        window.open('../../projects/<%=@project.identifier%>/issues?set_filter=1&f%5B%5D=status_id&op%5Bstatus_id%5D=%3D&v%5Bstatus_id%5D%5B%5D=<%=cat.id%>&f%5B%5D=&c%5B%5D=status&c%5B%5D=priority&c%5B%5D=subject&c%5B%5D=author&c%5B%5D=assigned_to&c%5B%5D=start_date&c%5B%5D=due_date&c%5B%5D=spent_hours&c%5B%5D=done_ratio&group_by=');
                                }
                        },
                   dataLabels: {
                                                        enabled: true,
                                                        rotation: -90,
                                                        color: '#FFFFFF',
                                                        align: 'right',
                                                        x: -3,
                                                        y: 10,
                                                        formatter: function() {
                                                                return this.y;
                                                        },
                                                        style: {
                                                                font: 'normal 13px Verdana, sans-serif'
                                                        }
                                                }
                  }<%if !(@statuses.last == cat)%>,<%end%>
                 <%end%>
                ]
	});
});
</script>

<!--
 Task Management / Gerenciamento de Tarefas
-->
<script type="text/javascript">
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
	     	credits: {
	 		  enabled: false
			},
            chart: {
                renderTo: 'managementissues',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: '<%=t :task_manageable_chart_title %>'
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.y,0)+ ' <%=t :tasksof_label%> '+<%= @project.issues.count %>;
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
					showInLegend: true,
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
						distance: 0,
                        formatter: function() {
                            return Highcharts.numberFormat(this.percentage,2) +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'Tarefas por Situação',
                data: <%=@managementissues.map{ |issue| [issue.typemanagement.to_s, issue.totalissues.to_i]}.inspect.html_safe%>
            }]
        });
    });
    
});
</script>

<script type="text/javascript">
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
	     	credits: {
	 		  enabled: false
			},
            chart: {
                renderTo: 'delayedissues',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: '<%=t :task_manageable_chart_overdue_title %>'
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.y,0)+ ' <%=t :tasksof_label%> '+<%= @managementissues.first.totalissues %>+' <%=t :manageable_label%>';
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
					showInLegend: true,
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
						distance: 0,
                        formatter: function() {
                            return Highcharts.numberFormat(this.percentage,2) +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'Tarefas atrasadas',
                data: <%=@overdueissueschart.map{ |issue| [issue.typeissue.to_s, issue.totalissuedelayed.to_i]}.inspect.html_safe%>
            }]
        });
    });
    
});

</script>

<script type="text/javascript">
$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
			credits: {
	 		  enabled: false
			},
            chart: {
                renderTo: 'categoryPie',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: '<%=@project.name%>'
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.y,0) +' <%=t :tasks_label%>';
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage,2) +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                data: <%=@issuesbycategory.map{ |category| [category.name.to_s, category.totalbycategory.to_i]}.inspect.html_safe%>
            }]
        });
    });
    
});
</script>

<script type="text/javascript">
var chart;
$(document).ready(function() {
	chart = new Highcharts.Chart({
		chart: {
			renderTo: 'categoryStackedColumn',
			type: 'column'
		},
		title: {
			text: '<%=@project.name%>'
		},
		subtitle: {
			text: '<%=t :categories_issue_label_title%>'
		},
		scrollbar:{
            enabled: false
        },
     	credits: {
 		  enabled: false
		},
		xAxis: {
			categories: [
			   <% @issuesbycategory.each do |cat| %>
   			     <%= cat.name.to_s.inspect.html_safe %>,
			   <%end%>
			],
			labels: {
				rotation: -45,
				align: 'right',
				style: {
					font: 'normal 13px Verdana, sans-serif'
				}
			}
		},
		yAxis: {
			min: 0,
			title: {
				text: ''
			}
		},
		legend: {
			enabled: true,
			reversed: true
		},
		tooltip: {
			formatter: function() {
				return ''+
					this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)';
			}
		},
		plotOptions: {
			column: {
				stacking: 'percent'
			}
		},
			series: [
			{
			name: '<%=t :tobedelivered_label%>',
			data: [
			 	   	<% @issuesbycategory.each do |cat| %>
     			      <%= cat.totalundone %>,
			        <%end%>
				  ]	,
					color: '#AA4643'
		    },
				{
				name: '<%=t :delivered_label%>',
				data: [
				 	   <% @issuesbycategory.each do |cat| %>
         			      <%= cat.totaldone %>,
	       		       <%end%>				  
				]	,
					color: '#4572A7'
			    }
				
		]
	});
});
</script>